-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Android: Add failOnWarnings check to android build.gradle and configure lint as warnings as error #12040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…re lint as warnings as error
@vinodhabib Please review and share feedback on any changes or improvements needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've done both (linter warnings and enabling -Werror) the mentioned issues in this PR. That's fine for me. @ejona86 should be able to tell us if we shouldn't be doing like this.
android/build.gradle
Outdated
lintOptions { abortOnError true } | ||
|
||
// fail on android lint warnings if failOnWarning is set true | ||
lintOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are doing this anyway, lintOptions is deprecated. Use lint instead. (Wait for Eric's comment on this before working)
android/build.gradle
Outdated
@@ -44,6 +52,14 @@ dependencies { | |||
testImplementation libraries.truth | |||
} | |||
|
|||
// Enforce -Werror on java compiler if failOnWarning is set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may remove the comments as they are self explanatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this fixing #6868? The issue talks about JavaCompile, but you removed that from the PR. Lint is good and helpful and we'll take it, but that was a bonus (and probably can't go in without a lot of fixes).
@ejona86 you're right - lint was an additional improvement, but I missed re-adding the JavaCompile configuration from the original intent of #6868. Initially I assumed that configuring tasks.withType(JavaCompile) globally already applied -Xlint:all and -Werror across all modules. I've now updated the PR to include both the lint block and the JavaCompile warnings, so all modules are covered. Please take another look, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build should be failing because of lint warnings. I expect there will be quite a few, which is why I was letting it be done separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks closer, but the build failure looks like it still remains.
@Sangamesh1997 For the old Android API targetted error that is causing the build failure, can you try adding the lint.xml exception mentioned here? |
Are you thinking we'd open a new issue to fix that? That is easy to fix, so I don't know why we would silence it instead of just fixing it. I could sort of understand if we want to silence all current lint failures so we stop introducing new ones, but really the warnings I've seen are really old so I was more concerned with fixing them, really. |
I assumed we really only cared about the minSdkVersion and that we didn't care about making any API changes needed for the latest Android version available. Now that I think about it I realize it is advantageous to do it rather than not do it , to be compatible with the latest platform advancements. |
Generally working with the new platform has been pretty easy for us; bump the number. Our users will be targeting newer versions, so if there is pain, they'd experience that pain. |
Android: Add failOnWarnings check to android build.gradle and configure lint as warnings as error.
Fixes: #6868